package com.canic.dkd.base.entity;

/**
 * api返回对象
 * @author ZC
 * @param <T>
 */
public class Result<T> {
    public static final Integer SUCCESS_CODE = 0;
    public static final Integer FAILURE_CODE = 1;

    public static final String SUCCESS_MSG = "请求成功";
    public static final String FAILURE_MSG = "请求失败";

    private Integer code;
    private String message;
    private T data;

    public static Result successResult(Object data) {
        return new Result(SUCCESS_CODE, SUCCESS_MSG, data);
    }

    public static Result failureResult(Object data) {
        return new Result(FAILURE_CODE, FAILURE_MSG, data);
    }

    public Result(){
    }

    public Result(Integer code, String message) {
        super();
        this.code = code;
        this.message = message;
    }

    public Result(String message, T data) {
        super();
        this.message = message;
        this.data = data;
    }

    public Result(Integer code, String message, T data) {
        super();
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
